package com.example.easyutils.openprize;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.easyutils.R;

import org.w3c.dom.Text;

import java.util.List;
import java.util.Map;

public class AdapterListView extends ArrayAdapter {

    private Context context;
    private List mList;
    private int resource;
    private TextView openTime,openExpect,openCode;
    public AdapterListView(@NonNull Context context, int resource, @NonNull List objects) {
        super(context, resource, objects);
        this.context = context;
        this.mList = objects;
        this.resource = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(resource,parent,false);
        openTime = (TextView)view.findViewById(R.id.openTime);
        openExpect = (TextView)view.findViewById(R.id.expect);
        openCode = (TextView)view.findViewById(R.id.openCode);

        openCode.setText("开奖号码:"+((Map)mList.get(position)).get("opencode").toString());
        openExpect.setText("期数:"+((Map)mList.get(position)).get("expect").toString());
        openTime.setText("日期:"+((Map)mList.get(position)).get("opentime").toString());
        return view;
    }
}
